package com.cxmx.escort.aspect.api;

import com.cxmx.escort.aspect.core.RedWineClientImpl;
import com.cxmx.escort.aspect.core.RedWineExaminationData;
import com.cxmx.escort.aspect.core.RedWineProperty;
import io.grpc.StatusRuntimeException;

import java.util.Map;

public interface RedWineClient {
    /**
     * Examines the given red wine data synchronously.
     * @param wineData the wine data, must contain all red wine properties @see core.RedWineProperty.
     * @throws IllegalArgumentException if wineData doesn't contain all red win properties @see core.RedWineProperty.
     * @throws StatusRuntimeException if there is a problem with rpc.
     * @return the examination result.
     */
    RedWineExaminationData examineRedWine(Map<RedWineProperty, Float> wineData)
            throws IllegalArgumentException, StatusRuntimeException;

    /**
     * Examines the given red wine data asynchronously.
     * @param wineData the wine data, must contain all red wine properties @see core.RedWineProperty.
     * @param resultCallback the callback to invoke when result is received or when error occurred.
     */
    void examineRedWineAsync(Map<RedWineProperty, Float> wineData,
                             final RedWineClientImpl.RedWineResultCallback resultCallback);
    
    /**
     * Shutdown the client. After calling this function the client
     * waits for preexisting calls to finish while preventing new calls to
     * be made.
     * @throws InterruptedException if thread is interrupted while waiting for
     *  preexisting calls to finish.
     */
    void shutdown() throws InterruptedException;
}
